import sqlite3

from contextlib import contextmanager

from config.settings import get_settings 

# create conn obj 

@contextmanager 
def create_curs(): 
    db = get_settings().root / get_settings().database_name
    conn = sqlite3.connect(db, check_same_thread=False)
    curs = conn.cursor()
    try: 
        yield curs 
        conn.commit()
    except sqlite3.Error: 
        conn.rollback()
        raise 
    finally: 
        curs.close()
        conn.close()




